package com.ctbu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ctbu.entity.BankInfo;
import com.ctbu.mapper.BankInfoMapper;
import com.ctbu.service.BankInfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ctbu.tools.ResponseResult;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;

/**
 * <p>
 * 银行信息表 服务实现类
 * </p>
 *
 * @author lli
 * @since 2024年06月19日
 */
@Service
public class BankInfoServiceImpl extends ServiceImpl<BankInfoMapper, BankInfo> implements BankInfoService {

    @Autowired
    private BankInfoMapper bankInfoMapper;

    @Override
    public ResponseResult<Object> selectList(int pageNum, int pageSize, String bankName) {
        //开启分页
        PageHelper.startPage(pageNum,pageSize);
        //条件(模糊)查询
        /*LambdaQueryWrapper<BankInfo> lambdaQueryWrapper=new LambdaQueryWrapper<>();
        if(!bankName.equals("")){
            lambdaQueryWrapper.like(BankInfo::getBankName,bankName);
        }*/
        QueryWrapper<BankInfo> queryWrapper=new QueryWrapper<>();
        if(StringUtils.isEmpty("")){
            queryWrapper.like("bank_name",bankName);
        }

        //List<BankInfo> list = bankInfoMapper.selectList(lambdaQueryWrapper);
        List<BankInfo> list = bankInfoMapper.selectList(queryWrapper);
        //将查询结果封装到对应分页中
        PageInfo<BankInfo> pageInfo = new PageInfo<>(list);
        return ResponseResult.success(pageInfo,"查询成功");


    }
}
